<#--<#macro Tab times=-1><#if times!=''><#if times gt 0><#list 1..times as i>${'\t'}</#list></#if><#else>${'\t'}</#if></#macro>-->
<#macro Tab times=-1><#if times gt 0><#list 1..times as i>${'\t'}</#list><#elseif times lt 0>${'\t'}</#if></#macro>

<#--包名标签-->
<#macro Package>
package ${clazz.packageName};
</#macro>

<#--引用标签-->
<#macro Reference>
<#list clazz.imports as import>
import ${import};
</#list>
<#nested>
</#macro>

<#--类注释-->
<#macro ClassCommnet>
/**
* @Description ${entity.table.comment}
* @Author  ${context.author}
* @Date ${createTime?string('yyyy-MM-dd HH:mm:ss')}
*/
</#macro>

<#macro Title >
<@Package/>

<@Reference/>
<#nested>

<@ClassCommnet/>
</#macro>

<#--类注解-->
<#macro ClassAnnotation>
<#nested>
</#macro>

<#--类-->
<#-- parentName 父类名称 -->
<#macro Class static = false abstract = false interface = false  name='' tabTimes=0 extends='false' implements='false'>
<@Tab times=tabTimes/>public<#if static> static</#if><#if abstract> abstract</#if> <#if interface>interface<#else>class</#if> <#if name!=''>${name}<#else>${clazz.name}</#if><#if extends=='true'> extends ${clazz.parent.name}<#elseif extends!='false'> extends ${extends}</#if><#if implements=='true'> extends ${clazz.parent.name}<#elseif implements!='false'> implements ${implements}</#if>{
<#nested>
<@Tab times=tabTimes/>}
</#macro>

<#--成员变量-->
<#-- type 0 全部 1只显示主键 2显示非主键(全部) 3显示唯一索引字段 4显示非主键(排除唯一索引字段) 5显示组合字段 6显示非组合字段 7显示非主键(排除组合字段)-->
<#macro Field field type = 0 onlyCondition=false comment = true comments ='' showParent = false useSwagger = false useValidation=false useJpa = false useMabtis = false dateTimeFormat=false onlyString = false tabTimes=1>
<#if !field.parentIncluded || showParent>
    <#if type==0||(type == 1 && field.column.primaryKey)
        ||(type == 2 && !field.column.primaryKey)
        ||type == 3 &&field.column.uniqueKey
        ||(type==4&&!field.column.primaryKey&&!field.column.uniqueKey)
        ||(type==5&&field.column.isCombine)
        ||(type==6&&!field.column.isCombine)
        ||(type==7&&!field.column.isCombine&&!field.column.primaryKey)
    >
        <#if !onlyString||field.type=='String'>
            <#if !onlyCondition||field.isCondition>
<#if comment>
<@Tab times=tabTimes/>/**
<@Tab times=tabTimes/>* <#if comments!=''>comments<#else >${field.column.comment}</#if>
<@Tab times=tabTimes/>*/
</#if>
<#nested>
<#if dateTimeFormat&&field.type=='Date'&&entity.containsDate>
<@Tab times=tabTimes/>@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
<@Tab times=tabTimes/>@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
</#if>
<#if useJpa>
<#if field.column.primaryKey>
<@Tab times=tabTimes/>@Id
<@Tab times=tabTimes/>@GeneratedValue(strategy = GenerationType.<#if field.column.autoIncrement>IDENTITY<#else>AUTO</#if>)
</#if>
<@Tab times=tabTimes/>@Column(name = "${field.column.name}"<#if !field.column.nullable>, nullable = false</#if>)
</#if>
<#if useMabtis>
<#if field.column.primaryKey>
<@Tab times=tabTimes/>@TableId(value = "id",type = IdType.<#if field.column.autoIncrement>AUTO<#else>ASSIGN_ID</#if>)
</#if>
<@Tab times=tabTimes/>@TableField(value = "${field.column.name}"<#if field.column.nullable>,updateStrategy = FieldStrategy.IGNORED</#if>)
</#if>
<#if useSwagger><@Tab times=tabTimes/>@ApiModelProperty(value = "${field.column.comment}<#if field.column.remark??>(${field.column.remark})</#if>"<#if !field.column.nullable>, required = true</#if><#if field.isCombine>,hidden=true</#if>)
</#if>
<#if useValidation&&!field.column.nullable><@Tab times=tabTimes/><#if field.type=='String'>@NotBlank(message = "${field.column.comment}不能为空")<#else>@NotNull(message = "${field.column.comment}不能为空")</#if>
</#if>
<@Tab times=tabTimes/>private ${field.type} ${field.name};
            </#if>
        </#if>
    </#if>
</#if>
</#macro>

<#macro FieldName field isInitial=false prefix=''><#if prefix!=''>${prefix}</#if><#if isInitial||prefix!=''>${field.capitalizeName}<#else>${field.name}</#if></#macro>

<#macro CreateTime useSwagger = false comment = true sql = false>
<#if comment>
${'\t'}/**
${'\t'}* 创建时间
${'\t'}*/
</#if>
<#if useSwagger>
${'\t'}@ApiModelProperty(value = "创建时间")
</#if>
<#if sql>
${'\t'}@SqlColumn(name = "create_time", setNullable = false)
</#if>
${'\t'}private Date createTime;
</#macro>

<#macro UpdateTime useSwagger = false comment = true sql = false>
<#if comment>
${'\t'}/**
${'\t'}* 更新时间
${'\t'}*/
</#if>
<#if useSwagger>
${'\t'}@ApiModelProperty(value = "更新时间")
</#if>
<#if sql>
${'\t'}@SqlColumn(name = "update_time", setNullable = false)
</#if>
${'\t'}private Date updateTime;
</#macro>


<#macro Deleted useSwagger = false comment = true sql = false>
<#if comment>
${'\t'}/**
${'\t'}* 逻辑删除标志
${'\t'}*/
</#if>
<#if useSwagger>
${'\t'}@ApiModelProperty(value = "逻辑删除标志")
</#if>
<#if sql>
${'\t'}@SqlColumn(name = "deleted", setNullable = false)
</#if>
${'\t'}private Boolean deleted;
</#macro>